<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
class Games extends CI_Model {

	public function __construct()
	{
		$this->load->database();
	}
	
	public function insertAllGames($arrayOfGames)
	{
		foreach ($arrayOfGames as $row) {
			$this->db->insert('game', $row);
		}
	}
	
	public function loadAllGames()
	{
		$query = $this->db->get('game');
		return $query->result_array();
	}
	
	public function loadAllGamesOfDate($formatedDate)
	{
		// za sad se funkciji mora dati datum u formatu "Friday 31-Aug"
	}
	public function loadLastDateGames()
	{
		$result = $this->db->query('select dateFromPage from game order by id desc limit 1');
		$data = $result->result_array();
		$dataarray=$data[0];
		// select * from articles order by artid desc limit 1;
		// $query = $this->db->get('game', 1);
		// $lastEntry = $query->result();
		// $lastDate= $lastEntry[0]->dateFromPage;
		$this->db->where('dateFromPage', $dataarray['dateFromPage']);		
		 $query = $this->db->get('game');
		 return $query->result_array();
	}
}